

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Edit Event</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><g:link class="home" controller="event"  action="home">Home</g:link></span>
            <span class="menuButton"><g:link class="list" action="list">Event List</g:link></span>
            <span class="menuButton"><g:link class="create" action="create">New Event</g:link></span>
            <span class="menuButton"><g:link controller="user" action="logout">Logout</g:link></span>

        </div>
        <div class="body">
            <h1>Edit Event</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${event}">
            <div class="errors">
                <g:renderErrors bean="${event}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <input type="hidden" name="id" value="${event?.id}" />
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="coordinator">Coordinator:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:event,field:'coordinator','errors')}">
                                    <g:select optionKey="id" from="${User.list()}" name="coordinator.id" value="${event?.coordinator?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="date">Date:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:event,field:'date','errors')}">
                                    <g:datePicker name="date" value="${event?.date}" ></g:datePicker>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="dateCreated">Date Created:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:event,field:'dateCreated','errors')}">
                                    <g:datePicker name="dateCreated" value="${event?.dateCreated}" ></g:datePicker>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="description">Description:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:event,field:'description','errors')}">
                                    <input type="text" id="description" name="description" value="${fieldValue(bean:event,field:'description')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="name">Name:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:event,field:'name','errors')}">
                                    <input type="text" id="name" name="name" value="${fieldValue(bean:event,field:'name')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="positiones">Positions:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:event,field:'positiones','errors')}">
<table>
<g:each var="p" in="${event?.positiones}">
    <tr>
    <td><g:link controller="positione" action="show" id="${p.id}">${p.name}</g:link></td>
    <td><g:link class="edit" controller="positione" action="edit" id="${p.id}">
            Edit Position
        </g:link></td>
    </tr>
</g:each>
</table> <p>
<g:link controller="positione" params="['event.id':event?.id]" action="create">Add Position</g:link></p>

                                </td>
                            </tr> 
                        
                        </tbody>
                    </table>
                    * In order to remove a position, just delete the position
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" value="Update" /></span>
                    <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>